home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Commun⁄Network / RevRdist Folder / RevRdist / headers / RevRdist.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-29  |  12.4 KB  |  371 lines  |  [TEXT/KAHL]

  1. /*
  2.  * RevRdist.h - #defines and declarations needed for most of the
  3.  * other files making up RevRdist
  4.  */
  5.  
  6. #include <Files.h>
  7. #include <string.h>
  8. #include "C_config.h"
  9.  
  10. typedef    StringPtr        SP;
  11.  
  12. /*
  13.  * Defn's which Apple should supply, but doesn't
  14.  */
  15. #define    afpAlreadyMounted    -5062    /* volume already mounted error */
  16. #define    fLocked        0x01            /* Finder locked flag */
  17. #define    fProtect    0x40            /* Finder protected flag */
  18.  
  19. /*
  20.  * e_action - the list of possible actions to apply to a file/folder
  21.  *        note: order is important
  22.  */
  23.  
  24. enum e_action
  25. {
  26.      A_DEFAULT = 0                    /* not specified */
  27.     ,A_PASS                            /* ignore this criterion */
  28.     ,A_IGNORE                        /* leave alone */
  29.     ,A_JUNK                            /* move to "junk" folder */
  30.     ,A_DISCARD                        /* remove permanently */
  31.     ,A_UPDATE                        /* copy from server */
  32. };
  33. typedef enum e_action action_t;
  34. #define    A_SET    A_JUNK                /* more mnemonic for some criteria */
  35.  
  36. /*
  37.  * e_ctype - the types of cat_nodes
  38.  */
  39. enum e_ctype
  40. {
  41.      C_FOLDER                        /* node represents folder */
  42.     ,C_FILE                            /* node represents file */
  43. };
  44. typedef enum e_ctype ctype_t;
  45.  
  46. /*
  47.  * e_dtype - the types of dist_nodes
  48.  */
  49.  
  50. enum e_dtype
  51. {
  52.      D_FOLDER                        /* node represents a folder */
  53.     ,D_FILE                            /* node represents a file */
  54.     ,D_FOLDERDEF                    /* node holds folder defaults */
  55. };
  56. typedef enum e_dtype dtype_t;
  57.  
  58. /*
  59.  * actions - list of actions to apply under given conditions
  60.  */
  61.  
  62. struct actions
  63. {
  64.     action_t    ifclient;            /* C if on client but not server */
  65.     action_t    ifserver;            /* S if on server but not client */
  66.     action_t    ifcreate;            /* V if server copy has different creation date */
  67.     action_t    ifnewer;            /* N if server copy is newer */
  68.     action_t    ifolder;            /* O if server copy is older */
  69.     action_t    ifsize;                /* Z if server copy is different size */
  70.     action_t    otherwise;            /* E if none of the above apply */
  71.     action_t    copywindow;            /* W set client window posn from server*/
  72.     action_t    invisible;            /* H set client object invisible */
  73.     action_t    locked;                /* L set client object locked */
  74.     action_t    backup;                /* B make backup before updated */
  75.     action_t    reboot;                /* R restart if updated */
  76. };
  77. typedef struct actions    actions_t;
  78.  
  79. /*
  80.  * dist_node - the structure of an entry read from the control file.
  81.  * These are linked into a tree which mimics the significant subset
  82.  * of the folder structure on the client disk.
  83.  */
  84.  
  85. struct    dist_node
  86. {
  87.     struct dist_node *    sibp;        /* sibling node */
  88.     struct dist_node *    childp;        /* child node */
  89.     struct dist_node *    parentp;    /* parent node */
  90.     struct type_node *    tlistp;        /* start of file type list */
  91.     StringPtr            altname;    /* name on server (when different) */
  92.     struct actions        actions;    /* condition/action list for node */
  93.     dtype_t                d_type;        /* type of node */
  94.     unsigned char        name[32];    /* component of path name */
  95. };
  96. typedef struct dist_node dnode_t;
  97.  
  98. /*
  99.  * type_node - a list of file types/creators also read from the
  100.  * control file.  Used to select files by type/creator instead of name.
  101.  * These are linked into a tree in which the leaves and intermediate
  102.  * nodes point back toward the root.  The tlistp pointer in a directory
  103.  * dist_node gives the start of a type_node chain which applies to files
  104.  * in that directory.
  105.  */
  106.  
  107. struct    type_node
  108. {
  109.     struct type_node *    morep;        /* upward link */
  110.     OSType                ftype;        /* file type */
  111.     OSType                fcreator;    /* file creator */
  112.     struct actions        actions;    /* actions to apply if file type/
  113.                                      *  creator match above */
  114. };
  115. typedef struct type_node    tnode_t;
  116.  
  117. /*
  118.  * cat_node - the structure for saving information from GetCatInfo
  119.  */
  120.  
  121. struct    cat_node
  122. {
  123.     struct cat_node *    link;        /* next file/folder in list */
  124.     Longint                dirID;        /* file/folder directory id */
  125.     Longint                parID;        /* dirID of containing folder */
  126.     unsigned long        crDate;        /* (file) creation date */
  127.     unsigned long        mdDate;        /* (file) modification date */
  128.     union
  129.     {
  130.         struct
  131.         {
  132.             FInfo        finfo;        /* (file) Finder info */
  133.             Longint        fileLen;    /* (file) data fork length */
  134.             Longint        rsrcLen;    /* (file) resource fork length */
  135.         } f;
  136.         struct
  137.         {
  138.             DInfo        dinfo;        /* (folder) Finder info */
  139.             Point        frScroll;    /* (folder) scroll posn */
  140.             Longint        frOChain;    /* (folder) open chain */
  141.         } d;
  142.     } in;
  143.     Byte                attrib;        /* file/folder attribute byte */
  144.     Byte                access;        /* (AppleShare) access rights */
  145.     ctype_t                ctype;        /* file/folder */
  146.     unsigned char        name[32];    /* the component name */
  147. };
  148. typedef struct cat_node cnode_t;
  149.  
  150. #include "junkp.h"
  151.  
  152. /*
  153.  * e_psind - index into preferences string array
  154.  */
  155. enum e_psind
  156. {
  157.      PS_ZONE                        /* name of AppleShare server zone */
  158.     ,PS_SRVR                        /* name of AppleShare server */
  159.     ,PS_USER                        /* user name on server */
  160.     ,PS_PASS                        /* user's password */
  161.     ,PS_DISTF                        /* path to distribution control file */
  162.     ,PS_MASTF                        /* full path to master folder */
  163.     ,PS_JUNKF                        /* name of junk folder */
  164.     ,PS_MAX                            /* count of number of strings */
  165.     ,PS_TIME                        /* boot-time run interval */
  166. };
  167. typedef enum e_psind psind_t;
  168. /* NOTE: any changes to the above must be reflected in the prefinfo
  169.  * structure in pref.c
  170.  */
  171.  
  172. /*
  173.  * prefs - Preferences information
  174.  */
  175.  
  176. struct prefs
  177. {
  178.     StringHandle    p[PS_MAX];        /* handles to preference strings */
  179.     unsigned long    p_interval;        /* running interval */
  180.     junkp_t            p_jparam;        /* junking parameters */
  181.     Boolean            p_modified;        /* values have changed */
  182. };
  183. typedef    struct prefs prefs_t;
  184.  
  185. /*
  186.  * e_pindex - index into preferences array
  187.  */
  188.  
  189. enum e_pindex
  190. {
  191.      P_WORK    = 0                        /* the preference values to use */
  192.     ,P_FILE                            /* preference values from pref file */
  193. };
  194. typedef    enum e_pindex pindex_t;
  195.  
  196. /*
  197.  * file_info - information about important files/folders
  198.  */
  199.  
  200. struct file_info
  201. {
  202.     StringHandle    f_path;            /* full path name of file/folder */
  203.     Integer            f_vol;            /* vRefNum giving vol for file */
  204.     Integer            f_ref;            /* refNum of file/working dir if open */
  205.     Boolean            f_launch;        /* true if supplied at launch */
  206.     Boolean            f_set;            /* true if list entry initialized */
  207.     cnode_t            f_info;            /* the bulk of the information */
  208. };
  209. typedef struct file_info file_info_t;
  210.  
  211. /*
  212.  * f_index - index of file info in file_info array
  213.  */
  214.  
  215. enum f_index
  216. {
  217.      FL_APPL                        /* the Application */
  218.     ,FL_PREF                        /* preference file */
  219.     ,FL_DIST                        /* dist control file */
  220.     ,FL_MAST                        /* master folder */
  221.     ,FL_JUNK                        /* junk folder */
  222.     ,FL_ROOT                        /* client root folder */
  223.     ,FL_TEMP                        /* temp file */
  224.     ,FL_MAX                            /* how many files */
  225. };
  226. typedef enum f_index findex_t;
  227.  
  228.  
  229. /*
  230.  * e_pending - Pending action to perform (values for Pending)
  231.  */
  232. enum e_pending
  233. {
  234.      PA_NULL = 0                    /* nothing pending */
  235.     ,PA_PREF                        /* invoke preferences dialog */
  236.     ,PA_GO                            /* (try to) go to it */
  237. };
  238. typedef enum e_pending pending_t;
  239.  
  240.  
  241. /*
  242.  * e_rstat - Running state
  243.  */
  244. enum e_rstat
  245. {
  246.      S_IDLE = 0                        /* idle, accepting commands */
  247.     ,S_RUNNING                        /* scanning & matching */
  248.     ,S_PAUSED                        /* paused while scanning */
  249. };
  250. typedef enum e_rstat rstat_t;
  251.  
  252. /*
  253.  * Useful macros
  254.  */
  255. #define COPYPS(s,d)    BlockMove (s, d, (Size)(((s)[0]) + 1))    /* copy pas. str */
  256. #define DISPLAY(s)    DisplayString ((StringPtr) s)
  257. #define    ZERO(s)        memset ((char *)&(s), 0, sizeof (s))    /* zero struct */
  258. #define ZEROAT(s)    memset ((char *)(s), 0, sizeof (*(s)))    /* zero *struct * */
  259.  
  260. /*
  261.  * Declarations for global variables
  262.  */
  263. extern WindowPtr        ActivityWind;    /* window for listing actions */
  264. extern OSType            AliasCreator;    /* pseudo-creator for Finder alias files */
  265. extern OSType            AliasType;    /* pseudo-type for Finder alias files */
  266. extern AppFile            Ap_file;    /* our argument file */
  267. extern Integer            Ap_refNum;    /* file refNum of application */
  268. extern Str255            Ap_volName;    /* name of volume Ap is running from */
  269. extern Integer            BlessedWD;    /* current system folder */
  270. extern Integer            BootVol;    /* vRefNum of boot volume */
  271. extern Longint            ClientClp;    /* client volume clump size */
  272. extern Longint            ClientClpM;    /* client volume clump size mask */
  273. extern Longint            ClientRoot;    /* directory id of client root */
  274. extern unsigned long    ClientSp;    /* client volume space remaining */
  275. extern Integer            ClientVol;    /* client volume VRefNum */
  276. extern Str31            ClientVolName;    /* client volume name */
  277. extern GetVolParmsInfoBuffer ClientVIB;    /* info about client volume */
  278. extern OSErr            ClueID;        /* error message STR# index */
  279. extern StringPtr        Clue0;        /* name of RevRdist routine detecting
  280.                                      * error */
  281. extern StringPtr        Clue1;        /* name of MacOS routine detecting
  282.                                      * error, or other error hint */
  283. extern StringPtr        Clue2, Clue3;    /* more hints */
  284. extern short            Depth;        /* folder depth */
  285. extern short            ErrorMsgs;    /* count of messages in ErrorWind */
  286. extern WindowPtr        ErrorWind;    /* error message window */
  287. extern file_info_t *    File_list;    /* pointer to array of file info */
  288. extern long                Flags;        /* processing flags */
  289. #define    PF_ECHODIST        0x00000001    /* echo control file as read */
  290. #define PF_LISTONLY        0x00000002    /* list actions without doing them */
  291. #define PF_STARTUP        0x00000004    /* running as startup application */
  292. #define    PF_VERBOSE        0x00000008    /* list everything */
  293. #define    PF_NOMOUNT        0x00000010    /* don't mount/unmount server volume as needed */
  294. #define    PF_UNMOUNTS        0x00000020    /* always unmount server volume */
  295. #define    PF_RESTART        0x00000040    /* restart Mac when finished */
  296. #define    PF_QUITOTHERS    0x00000080    /* try to quit other applications at startup */
  297. #define    PF_LOCKED        0x00000100    /* disallow preference changes */
  298. #define    PF_DIALOG        0x00000200    /* bring up Flags dialog at start */
  299. #define    PF_TOUCH        0x00000400    /* change mod time of prefs file when done */
  300. #define    PF_FINDUPD        0x00000800    /* search for volume to update */
  301. #define    PF_BADSERVER    0x00001000    /* server unreliable */
  302.  
  303. extern unsigned char    HighValue[];/* string lexically after any file name */
  304. extern OSType            IconCreator;    /* pseudo creator for icon files */
  305. extern Str31            IconFName;    /* name Finder uses for icon files */
  306. extern OSType            IconType;    /* pseudo type for icon files */
  307. extern Byte                Junksuf[1+8];/* suffix to handle junk name conflicts */
  308. extern Str255            Mbuf;        /* temp string, often used for msgs */
  309. extern StringPtr        NullStr;    /* constant empty string */
  310. extern rstat_t            Pause;        /* running state */
  311. extern pending_t        Pending;    /* pending action */
  312. extern DialogPtr        PrefDialog;    /* preferences dialog window */
  313. extern prefs_t            Prefs[];    /* preferences values */
  314. extern Boolean            Quit;        /* true if requested to quit */
  315. extern Longint            ServerRoot;    /* ioDirID of master folder on server */
  316. extern Integer            ServerVol;    /* vRefNum of server volume */
  317. extern GetVolParmsInfoBuffer ServerVIB;    /* Info about server volume */
  318. extern DialogPtr        StatusDialog;    /* status window */
  319. extern Str31            TempName;    /* name for temp files */
  320. extern Str31            TempName2;    /* another temp file name */
  321. extern StringHandle        Untitled;    /* anonymous document name */
  322. extern CursHandle        Watch;        /* "busy" cursor */
  323.  
  324. #include "rsrc.h"
  325. /*
  326.  * prototypes for cross-file RevRdist functions
  327.  */
  328. extern OSErr            accessMaster (StringPtr, AFPVolMountInfo *);
  329. extern OSErr            createFolder (StringPtr, Integer, Longint, cnode_t *);
  330. extern OSErr            discard (cnode_t *, Boolean);
  331. extern void                dispIndStr (WindowPtr, Integer, Integer, StringPtr, ...);
  332. extern void                doPref (void);
  333. extern void                doWindowMenu (Integer);
  334. extern void                freeDist (dnode_t *);
  335. extern void                freeInfo (file_info_t *);
  336. extern void                freeList (cnode_t *);
  337. extern StringPtr        fullpath (StringPtr, Integer, Longint);
  338. extern OSErr            getInfo (StringPtr, Integer, Longint, cnode_t *);
  339. extern OSErr            getInfoByPath (StringPtr, file_info_t *);
  340. extern OSErr            getSet (void);
  341. extern void                initGlobals (void);
  342. extern cnode_t *        listFolder (Integer, Longint);
  343. extern OSErr            makeJunk (void);
  344. extern OSErr            moveToJunk (cnode_t *);
  345. extern void                notice (enum activity_e, StringPtr, ...);
  346. extern void                panic (Boolean, enum error_e, StringPtr, ...);
  347. extern void                prefDoEMenu (Integer);
  348. extern void                prefDoFMenu (Integer);
  349. extern OSErr            prefFetch (Integer);
  350. extern OSErr            prefFFetch (file_info_t *);
  351. extern void                prefMerge (pindex_t, Boolean);
  352. extern StringPtr        pstrcat (StringPtr dest, StringPtr src);
  353. extern StringPtr        pstrcat2 (StringPtr dest, StringPtr, StringPtr);
  354. extern OSErr            relock (cnode_t *);
  355. extern void                saveCatInfo (CInfoPBRec *, cnode_t *);
  356. extern void                setFlags (void);
  357. extern void                setStat (void);
  358. extern void                statMsg (StringPtr);
  359. extern void                statMsgClr (void);
  360. extern void                showstat (void);
  361. extern void                TextDialog (int dlogNum, Handle textHandle,
  362.                             int fontNum, int fontSize, Boolean wrap);
  363. extern void                tidyUp (void);
  364. extern OSErr            touch(Integer vol, cnode_t *sp);
  365. extern OSErr            unlock (cnode_t *);
  366. extern void                updateRoot (dnode_t *);
  367. extern OSErr            update_alias (cnode_t *);
  368. extern void                verifyBlessed (void);
  369. extern void                warning (enum error_e, StringPtr, ...);
  370.  
  371. // #include <MacProto.h>